import 'package:fluwx/fluwx.dart' as fluwx;
import 'package:hm_show_flutter/entity/share.dart';

class ShareUtil {
  static void shareWx(ShareModel model) {
    if (model == null) {
      return;
    }
    fluwx.WeChatShareModel share;
    if (model.url != null) {
      share = new fluwx.WeChatShareWebPageModel(
          webPage: model.url,
          description: model.content,
          title: model.title,
          scene: fluwx.WeChatScene.SESSION,
          thumbnail: model.imgUrl);
    } else {
      share = new fluwx.WeChatShareImageModel(
          image: model.imgUrl,
          description: model.content,
          title: model.title,
          scene: fluwx.WeChatScene.SESSION,
          thumbnail: model.imgUrl);
    }
    fluwx.shareToWeChat(share);
  }

  static void shareWxCircle(ShareModel model) {
    if (model == null) {
      return;
    }
    fluwx.WeChatShareModel share;
    if (model.url != null) {
      share = new fluwx.WeChatShareWebPageModel(
          webPage: model.url,
          description: model.content,
          title: model.title,
          scene: fluwx.WeChatScene.TIMELINE,
          thumbnail: model.imgUrl);
    } else {
      share = new fluwx.WeChatShareImageModel(
          image: model.imgUrl,
          description: model.content,
          title: model.title,
          scene: fluwx.WeChatScene.TIMELINE,
          thumbnail: model.imgUrl);
    }
    fluwx.shareToWeChat(share);
  }
}
